import {
    FormItemType,
    UserState
} from 'assets/js/Constant'

import { handleOnValidate2LoginName } from "assets/js/Validate";

const columns = [{
    title: '编号',
    dataIndex: 'id',
    key: 'id',
    slots: {
        title: 'id',
        customRender: 'id'
    },
},
{
    title: '用户编号',
    dataIndex: 'userNum',
    key: 'userNum',
    slots: {
        customRender: 'userNum'
    },
},
{
    title: '昵称',
    dataIndex: 'nickName',
    key: 'nickName',
    slots: {
        customRender: 'nickName'
    }
},
{
    title: '真实姓名',
    dataIndex: 'realName',
    key: 'realName',
    slots: {
        customRender: 'realName'
    }
},
{
    title: '头像',
    dataIndex: 'avator',
    key: 'avator',
    slots: {
        customRender: 'avator'
    }
},
{
    title: '性别',
    dataIndex: 'sex',
    key: 'sex',
    slots: {
        customRender: 'sex'
    }
},
{
    title: '用户状态',
    dataIndex: 'userStatus',
    key: 'userStatus',
    slots: {
        customRender: 'userStatus'
    }
},
{
    title: '创建时间',
    dataIndex: 'createTime',
    key: 'createTime',
    slots: {
        customRender: 'createTime'
    }
},
{
    title: '操作',
    key: 'action',
    slots: {
        customRender: 'action'
    },
},
];

const schema = {
    options: {
        labelCol: 8,
        wrapperCol: 18,
        layout: 'vertical',
    },
    groups: [{
        grid: 3,
        fields: [{
            type: FormItemType.INPUT,
            label: "登录账号",
            name: "loginName",
            rules: [
                { required: true, message: "请输入登录账号" },
                { validator: handleOnValidate2LoginName }
            ]
        },
        {
            type: FormItemType.SELECT,
            label: "归属角色组",
            name: "ruleGroupId",
            props: {
                label: "ruleGroupName",
                value: "id"
            },
            placeholder: "角色组"
        },
        {
            type: FormItemType.INPUT,
            label: "昵称",
            name: "nickName",
            rules: [{
                required: true,
                message: "请输入昵称"
            }]
        },
        {
            type: FormItemType.INPUT,
            label: "真实姓名",
            name: "realName",
            rules: [{
                required: true,
                message: "请输入真实姓名"
            }]
        },
        {
            type: FormItemType.RADIO,
            label: "性别",
            name: "sex",
            style: 'solid',
            rules: [{
                required: true,
                message: "请选择性别"
            }],
            props: {
                label: "label",
                value: "value"
            },
            sourceData: [{
                label: "男",
                value: 1
            },
            {
                label: "女",
                value: 0
            }]
        },
        {
            type: FormItemType.DATE, // date
            label: '生日',
            name: 'birthday',
            style: "date",
            format: "YYYY-MM-DD"
        },
        {
            type: FormItemType.SELECT,
            label: "用户状态",
            name: "userStatus",
            props: {
                label: "label",
                value: "value"
            },
            sourceData: UserState
        },
        {
            type: FormItemType.TEXTAREA,
            label: '备注',
            name: 'userDesc',
            placeholder: '个人介绍',
        }
        ]
    }]
};

const searchFormSchema = {
    options: {
        labelCol: 0,
        wrapperCol: 20,
        layout: 'inline',
    },
    groups: [{
        fields: [{
            type: FormItemType.INPUT,
            label: "昵称",
            name: "nickName",
            placeholder: "输入用户昵称",
        },
        {
            type: FormItemType.SELECT,
            label: "用户状态",
            name: "userStatus",
            props: {
                label: "label",
                value: "value"
            },
            placeholder: "选择用户状态",
            sourceData: UserState
        }]
    }]
};


export default {
    columns: columns,
    searchFormSchema: searchFormSchema,
    schema: schema
}